<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>{php}</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="Smarty 3 Manual">
<link rel="up" href="language.builtin.functions.html" title="Chapter 7. Built-in Functions">
<link rel="prev" href="language.function.nocache.html" title="{nocache}">
<link rel="next" href="language.function.section.html" title="{section},{sectionelse}">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">{php}</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="language.function.nocache.html">Prev</a> </td>
<th width="60%" align="center">Chapter 7. Built-in Functions</th>
<td width="20%" align="right"> <a accesskey="n" href="language.function.section.html">Next</a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect1" title="{php}">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="language.function.php"></a>{php}</h2></div></div></div>
<div class="note" title="IMPORTANT NOTICE" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">IMPORTANT NOTICE</h3>
<p>
      <code class="varname">{php}</code> tags are deprecated from Smarty, and should not be used. Put your
      PHP logic in PHP scripts or plugin functions instead.
   </p>
</div>
<div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>
   As of Smarty 3.1 the <code class="varname">{php}</code> tags are only available from <a class="link" href="bc.html" title="Chapter 19. SmartyBC - Backwards Compatibility Wrapper">SmartyBC</a>.
  </p>
</div>
<p>
  The <code class="varname">{php}</code> tags allow PHP code to be embedded directly into the template. They
  will not be escaped, regardless of the <a class="link" href="variable.php.handling.html" title="$php_handling"><em class="parameter"><code>$php_handling</code></em></a> setting.
 </p>
<div class="example">
<a name="id377967"></a><p class="title"><b>Example 7.61. php code within {php} tags</b></p>
<div class="example-contents"><pre class="programlisting">

{php}
   // including a php script directly from the template.
   include('/path/to/display_weather.php');
{/php}

  </pre></div>
</div>
<br class="example-break"><div class="example">
<a name="id378363"></a><p class="title"><b>Example 7.62. {php} tags with global and assigning a variable</b></p>
<div class="example-contents"><pre class="programlisting">

{* this template includes a {php} block that assign's the variable $varX *}
{php}
   global $foo, $bar;
   if($foo == $bar){
     echo 'This will be sent to browser';
   }
  // assign a variable to Smarty
  $this-&gt;assign('varX','Toffee');
{/php}
{* output the variable *}
&lt;strong&gt;{$varX}&lt;/strong&gt; is my fav ice cream :-)

  </pre></div>
</div>
<br class="example-break"><p>
  See also
  <a class="link" href="variable.php.handling.html" title="$php_handling"><em class="parameter"><code>$php_handling</code></em></a>,
  <a class="link" href="language.function.include.php.html" title="{include_php}"><code class="varname">{include_php}</code></a>,
  <a class="link" href="language.function.include.html" title="{include}"><code class="varname">{include}</code></a>,
  <a class="link" href="language.function.insert.html" title="{insert}"><code class="varname">{insert}</code></a>
  and
  <a class="link" href="tips.componentized.templates.html" title="Componentized Templates">componentized templates</a>.
 </p>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="language.function.nocache.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="language.builtin.functions.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="language.function.section.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">{nocache} </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> {section},{sectionelse}</td>
</tr>
</table>
</div>
</body>
</html>
